package com.jp.knowledge.dialog;

import android.app.Activity;
import android.view.View;
import android.widget.LinearLayout;

import com.jp.knowledge.R;
import com.jp.knowledge.adapter.OnItemListerner;

/**
 * Created by jiayen on 16/12/22.
 */

public class AttentionManagerPopuWindow extends BasePopupWindow implements View.OnClickListener {

    private OnItemListerner listener;
    public AttentionManagerPopuWindow(Activity context) {
        super(context);

        conentView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
        this.setWidth(conentView.getMeasuredWidth());
        this.setHeight(conentView.getMeasuredHeight());
    }

    @Override
    public int getLayoutId() {
        return R.layout.attention_manager_layout;
    }

    public void setOnItemListener(OnItemListerner listener) {
        this.listener = listener;
    }

    @Override
    public void initView() {
        int count = ((LinearLayout)conentView).getChildCount();
        for (int i = 0; i <count ; i++) {
            View view = ((LinearLayout)conentView).getChildAt(i);
            view.setTag(i);
            view.setOnClickListener(this);
        }
    }

    @Override
    public void onClick(View v) {
        try {
            int position = (int) v.getTag();
            if(listener!=null)
                listener.onItemClick(v,position);

        }catch (Exception e){

        }
        this.dismiss();
    }


}
